<template>
	<view>
		<view @tap.stop="to_detail" v-if="info" class="flex flex-x-b flex-y-center pf hidden"
			:style="`width: 100%; height: 78rpx; color: #323232; background-color: #BAD2FF; top: ${customBar}; left: 0;`">

			<view class="iconfont icon-gonggao fs-28 color-all" style="margin: 0rpx 20rpx 0rpx 32rpx;color:#FDD92F;">
			</view>
			<view class="fs-28 over-line1 flex-1">
				{{info.content}}
			</view>

			<view class="iconfont icon-jinru mr-20 fs-32" style="font-weight: 600;font-size: 32rpx;">
			</view>

		</view>
	</view>
</template>

<script>
	export default {
		name: 'xxxxx',
		props: {
			avatar: {
				type: [String, Number],
				default: '',
			},
			id: {
				type: [String, Number],
				default: '',
			},
			name: {
				type: [String, Number],
				default: '',
			},
			groupInfo: {
				type: Object,
				default: () => ({}),
			},
			role: {
				type: [String, Number],
				default: '',
			}


		},
		data() {
			return {
				customBar: getApp().globalData.customBar + 'px',
				info: null,
				// groupInfo: null,
				self: '',
			}
		},
		methods: {
			refresh() {

				if (!this.id) return;
				// if (!this.groupInfo) {
				// 	this.get_info();
				// }
				this.request({
					url: '/group/getNewGroupNotices',
					data: {
						groupId: this.id,
					},
					chat: true,
				}).then(res => {
					if (res.status == 200 && res.data) {
						this.info = res.data;
						this.info.time = this.dateFormat('YY-mm-dd HH:MM', new Date(this.info.createTime));
					}
				});
			},
			to_detail() {
				this.info.avatar = this.groupInfo.avatar || '';
				this.info.name = this.name || '';
				this.info.groupId = this.id || '';
				getApp().globalData.look_item = this.clone(this.info);
				this.info = null;
				let self = '';
				console.log('this.info',this.groupInfo)
				if(this.role || this.user_info.id == this.groupInfo.userId){
					self = 1;
				}
				this.toPage('/pages/chat/announcement-detail?self=' + self + '&groupId=' + this.id);
			},

			get_info() {
				this.request({
					url: '/getMembers',
					chat: true,
					// loading: true,
					data: {
						id: this.id
					}
				}).then(res => {
					if (res.status == 200 && res.data) {

						if (res.data.group) {
							if (res.data.group.userId == this.user_info.id) {
								this.self = 1;
							}
							this.groupInfo = res.data.group;

						}

					}
				});

			},
		}
	}
</script>

<style>
</style>
